<?php

// +----------------------------------------------------------------------
// | Banner api控制器
// +----------------------------------------------------------------------
// | @author fancsen
// +----------------------------------------------------------------------

/**
 * Banner api控制器
 * @author fancsen
 */


namespace app\api\controller\v1;

use app\api\validate\IDMustBePostiveInt;
use app\api\model\Banner as BannerModel;
use app\common\lib\exception\ApiException;

class Banner
{
    /**
     * 获取指定banner信息
     * @http get
     * @param number $id banner的id值
     * @return array
     */
    public function getBanner($id = null)
    {
        (new IDMustBePostiveInt())->goCheck();

        $banner = BannerModel::getBannerById($id);
        
        if(!$banner){
            throw new ApiException('请求的banner不存在',404,40000);
        }
        return json($banner);
        
    }

}